package com.tjetc.simplefactory;

import java.util.Objects;

/**
 * 工厂类
 */
public class ResourceFactory {
    /**
     * 创建对象的方法
     * @param type
     * @param path
     * @return
     */
    public static Resource create(String type, String path){
        Resource resource = null;
        if (Objects.equals("file", type)) {
            // file的处理逻辑 省略.....
            resource = new Resource(path);
        } else if (Objects.equals("http", type)) {
            // ..发起请求下载资源... 可能很复杂
            resource = new Resource(path);
        } else if (Objects.equals("classpath", type)) {
            resource = new Resource(path);
        } else {
            resource = new Resource("default");
        }
        return resource;
    }

}
